package com.example.demo.mapper;

import com.example.demo.entity.CSDNArticleEntity;
import com.example.demo.entity.CSDNAuthorEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface CSDNMapper {

    // 清空数据库
    public void clearArticle();
    public void clearAuthor();

    // 检查是否有某篇文章
    public int checkArticle(CSDNArticleEntity articleEntity);

    // 检查是否有某个作者
    public int checkAuthor(CSDNAuthorEntity authorEntity);

    // 插入一条数据
    public void insertOneArticle(CSDNArticleEntity articleEntity);

    // 插入一条作者数据
    public void insertOneAuthor(CSDNAuthorEntity authorEntity);

    // 更新一条数据
    public void updateOneArticle(CSDNArticleEntity articleEntity);

    public void updateOneAuthor(CSDNAuthorEntity authorEntity);

    // 从文章表中查询数据
    public List<CSDNArticleEntity> selectFromArticle(@Param("keyword") String keyword,
                                                     @Param("offset") Integer offset,
                                                     @Param("pagesize") Integer pagesize);
    // 查询一共有多少条数据
    public Integer selectCount(@Param("keyword") String keyword);

}
